
import 'package:flutter/material.dart';

class ListItem extends StatefulWidget{
  final String title;
  final IconData icon;
  final String path;
  ListItem({
    @required this.title,
    @required this.path,
    this.icon = Icons.keyboard_arrow_right
  });
  @override
  _StateListItem createState(){
    return _StateListItem();
  }
}

class _StateListItem extends State<ListItem>{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return ListTile(
      title:Text(
        widget.title,
        style: TextStyle(
          fontSize: 16
        ),
      ),
      trailing:Icon(widget.icon),
      onTap: () {
        if(widget.path.isNotEmpty){
          Navigator.pushNamed(context, widget.path);
        }else {
          showDialog(
            context: context
          );
        }
      },
    );
  }
}